#include "Product.h"
#include "AbstractFactory.h"

#include <iostream>
using namespace std;

void test()
{
    AbstractFactory* factory = nullptr;
    AbstractApple* apple = nullptr;
    AbstractBanana* banana = nullptr;
    AbstractPear* pear = nullptr;

    // 中国工厂
    {
        factory = new ChinaFactory;
        apple = factory->CreateApple();
        banana = factory->CreateBanana();
        pear = factory->CreatePear();
        apple->showName();
        banana->showName();
        pear->showName();
        delete pear;
        delete banana;
        delete apple;
        delete factory;
    }

    // 美国工厂
    {
        factory = new AmericaFactory;
        apple = factory->CreateApple();
        banana = factory->CreateBanana();
        pear = factory->CreatePear();
        apple->showName();
        banana->showName();
        pear->showName();
        delete pear;
        delete banana;
        delete apple;
        delete factory;
    }

    // 日本工厂
    {
        factory = new JapanFactory;
        apple = factory->CreateApple();
        banana = factory->CreateBanana();
        pear = factory->CreatePear();
        apple->showName();
        banana->showName();
        pear->showName();
        delete pear;
        delete banana;
        delete apple;
        delete factory;
    }
}

int main()
{
    test();
    return 0;
}